<template>
  <div id="box" v-loading="loading" element-loading-text="加载中">
    <iframe  ref="fIframe" id="child" :src="url" scrolling="auto" frameborder="0" seamless />
  </div>
</template>
<script>
// import { getPatientInfo } from '@/api/green-channel/tab-request'
import { showCpOutFollowUpDoctor } from '@/api/green-channel/tab-request'

export default {
  // 由主页面(父组件) 接收来的, 选择项的数据
  props: ['checkrowdata'], // 由主页面(父组件) 接收来的, 选择项的数据
  data() {
    return {
      url: '',
      loading: true,
      val:"",
    }
  },
  computed: {},
  updated() { },
  created() { },
  mounted() {
    this.url = process.env.VUE_APP_BASE_API_DATA_BRANCH + '/reportForm21?apiToken=' + this.$store.getters.apiToken + '&dispatchId=' + this.checkrowdata.dispatchId + '&hospitalId=' + this.$store.getters.hospitalId + '&medicalId=' + this.checkrowdata.medicalId + '&userId=' + this.$store.getters.userId + '&type=' + 'web'
    console.log(this.url, 'url')
    console.log(this.$store.getters.hospitalId, 'hospitalId')
    console.log("queryshowCpoutFollowUpDoctor()")
    this.queryshowCpoutFollowUpDoctor()
    const iframes = document.getElementById('child')
    if (iframes.attachEvent) {
      iframes.attachEvent('onload', () => {
        // iframe加载完毕以后执行操作
        this.loading = false
        // console.log('iframe已加载完毕1')
      })
    } else {
      iframes.onload = () => {
        // iframe加载完毕以后执行操作
        // console.log('iframe已加载完毕2')
        this.loading = false
        this.$refs.fIframe.contentWindow.postMessage(this.val,'*')
      }
    }
  },
  methods: {
    queryshowCpoutFollowUpDoctor() {
      showCpOutFollowUpDoctor(this.checkrowdata.dispatchId).then(res => {
        console.log(res)
        if(res.code ===0){
          val = res.data
        }
      })
    }
  }
}
</script>
<!-- http://121.40.195.34:12334/reportForm21?apiToken=0&dispatchId= -->
<style scoped>
#child {
  width: 100%;
  height: 100vh;
}
</style>
